package com.jargonee.adapters;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.jargonee.activities.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class JargoneeArrayAdapter<T> extends ArrayAdapter<JSONObject> {

	public JargoneeArrayAdapter(Context context, int textViewResourceId) {
		super(context, textViewResourceId);
		// TODO Auto-generated constructor stub
	}

	public JargoneeArrayAdapter(Context context, int resource, int textViewResourceId, List<JSONObject> objects) {
		super(context, resource, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
	}

	public JargoneeArrayAdapter(Context context, int resource, int textViewResourceId, JSONObject[] objects) {
		super(context, resource, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
	}

	public JargoneeArrayAdapter(Context context, int resource, int textViewResourceId) {
		super(context, resource, textViewResourceId);
		// TODO Auto-generated constructor stub
	}

	public JargoneeArrayAdapter(Context context, int textViewResourceId, List<JSONObject> objects) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
	}

	public JargoneeArrayAdapter(Context context, int textViewResourceId, JSONObject[] objects) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater)super.getContext().getSystemService(
			      Context.LAYOUT_INFLATER_SERVICE);
		View view;
		if(position == 0) {
			view = inflater.inflate(R.layout.jargonee_display_first_item, null);
			return view;
		}
		else
			view = inflater.inflate(R.layout.jargonee_display_item, null);
		
		JSONObject defintion = super.getItem(position);
		TextView definitionText = (TextView)view.findViewById(R.id.Definition);
		try {
			definitionText.setText(defintion.getString("word"));
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return view;
	}

	
}
